\begin{tikzpicture}[>=Stealth, scale=0.6, transform shape]
    \tikzset{
        pics/shuzhou/.style n args={4}{
            code = {
                \draw [->] (-1, 0) -- (9, 0);
                \foreach \x in {0, ..., 8} {
                    \draw (\x, 0.2) -- (\x, 0);
                }
                \draw (4, -1.2) node {\Large $(#1)$};
                \draw (#2, 0) node [below=0.4em] {\Large $O$};
                \filldraw [fill=black] (#3, 0) circle (0.08) node [below=0.4em] {\Large $A$};
                \filldraw [fill=black] (#4, 0) circle (0.08) node [below=0.4em] {\Large $B$};
            }
        }
    }

    \draw (0, 0) pic {shuzhou={1}{2}{4}{7}};
    \draw (12, 0) pic {shuzhou={2}{2}{0}{7}};

    \draw (0,  -2.5) pic {shuzhou={3}{7}{1}{5}};
    \draw (12, -2.5) pic {shuzhou={4}{1}{7}{3}};

    \draw (0,  -5) pic {shuzhou={5}{6}{8}{1}};
    \draw (12, -5) pic {shuzhou={6}{6}{4}{0}};
\end{tikzpicture}

